package org.luxor.accesslog.entity;

import io.swagger.annotations.ApiModel;
import org.luxor.commons.core.validator.group.AddGroup;
import org.luxor.commons.core.validator.group.Group;

import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.UUID;

/**
 * 访问日志对象
 *
 * @author Mr.yan @date 2020/3/11
 */
@ApiModel("访问日志对象")
public class AccessLogEntity {

    /**
     * 主键ID
     */
    @NotBlank(message = "主键ID，不能为空", groups = Group.class)
    private String id;

    /**
     * 访问用户登陆账号
     */
    @NotBlank(message = "用户名称，不能为空", groups = AddGroup.class)
    private String userName;

    /**
     * 访问来源IP
     */
    private String ip;

    /**
     * 所访问模块
     */
    @NotBlank(message = "模块名称，不能为空", groups = Group.class)
    private String module;

    /**
     * 详情描述
     */
    private String message;


    /**
     * 访问时间点
     */
    @NotBlank(message = "创建时间，不能为空")
    private Date time;

    public AccessLogEntity() {
        this.id = UUID.randomUUID().toString();
        this.time = new Date();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getModule() {
        return module;
    }

    public void setModule(String module) {
        this.module = module;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return "AccessLogEntity{" +
                "id='" + id + '\'' +
                ", userName='" + userName + '\'' +
                ", ip='" + ip + '\'' +
                ", module='" + module + '\'' +
                ", message='" + message + '\'' +
                ", time=" + time +
                '}';
    }
}
